
TErrorTable component for Borland Delphi

Are you frustrated with not being able to get more specific information when
encountering BDE errors in Delphi, especially with Paradox tables and validity
checks ?  Wouldn't it be nice if a min/max check fails and you could find out
what field is having the problem ?  Wouldn't it be nice if you could have a
central application exception handler and still be able to deal with (using
plain, non-cryptic messages) table-specific errors, such as key violations ?

Freeware, including source, from OnTYme Software.

TErrorTable is a descendant from TTable that allows you to attach specific
event handlers to the component for BDE errors such as key violations, min/
max checks, required checks (see below), etc.  The component also logs the
specific error contexts regarding the error when it occurs in properties in
the component.  This allows you to react to specific events for specific
tables and retrieve the necessary information to build a nice, non-frightening
message to display to the users.  Unfortunately, the built-in exception
messages in the BDE are far from understandable to an end user and are next
to impossible to parse in message format to derive the information needed
by you, the programmer, as to what exactly went wrong.  This is especially
true when dealing with highly-marketed end-user oriented programs using
local databases such as Paradox or DBase.  To take full advantage of the
component, especially with Paradox files, turn off all of the built-in Delphi
validity checks for the TFields by making the Required property false and
the Min/Max properties 0.  This will allow the TErrorTable to let the Paradox
validity checks take effect directly from the tables and will permit the
TErrorTable component to generate all exception events properly for you.

Currently, the errors that are trapped are as follows:

Key violations
Minimum validity checks
Maximum validity checks
Required checks
Master record missing (with referential integrity)
Lookup table fail
Record lock fail
Record unlock fail
File is locked by another user
Directory is locked by another user
Multiple .NET files in use
Detail records exist for a master (with referential integrity)
Other errors (none of the above)

******************************************************************************
One note, the required checks will not execute if you do not have a TField
object defined for a field and do not turn off (set to False) the Required
property.  The error will be trapped as a EDatabaseError exception, so to get
the most mileage out of the TErrorTable component you should always define
TField objects and set their Required properties to False.  This will let
Paradox and the TErrorTable component handle all exceptions.
******************************************************************************

All events pass the exception on to the event handler, so you are always able
to just display the original exception message if you wish.  Please note,
currently if you DO NOT attach an event handler the exception will be 
handled internally in the default error message processing.  If an error is
not an EDBEngineError or EDatabaseError then it will be handled by the 
OnOtherErrors event handler, or if one is not attached the default error
message processing for the OnOtherErrors type of error.

The event handlers are as follows:

OnKeyViolation
OnMinCheckFail
OnMaxCheckFail
OnFldRequired
OnMasterMissing
OnLookupTblFail
OnRecLockFail
OnRecUnLockFail
OnFileIsLocked
OnDirIsLocked
OnMultipleNetFiles
OnDetailRecordsExist
OnOtherErrors

New events in this version:

OnDetailRecordsExist	-	Triggered when there referential integrity is defined
								between the current table and a detail table and a
								a delete is attempted while there are still detail
								records present.

The error context properties are as follows:

ErrorToken
ErrorTableName
ErrorFieldName
ErrorImageRow
ErrorUserName
ErrorFileName
ErrorIndexName
ErrorDirName
ErrorKeyName
ErrorAlias
ErrorDriveName
ErrorNativeCode
ErrorNativeMsg
ErrorLineNumber
ErrorCapability


New properties in this version:

RecordNumber			-	Property for retrieving the current record number,
							 	or sequence number in Paradox tables.

TableDescription		-	This field is simply a place to store the description
								of the contents of the table.  This string is used
								in the default error message display when you do
								not have an event handler attached for that specific
								exception.


Other new functionality includes table callbacks for automatic refreshing and
guaranteed saving of data via the DbiSaveChanges BDE call.  Please see history
below for details.

******************************************************************************
Please note, all of these properties are read-only.  Also, don't get upset
if you can't retrieve any context information such as ErrorKeyName when a
key violation error occurs, for some reason the BDE doesn't log any info on
this error when it occurs.  Sorry !
******************************************************************************

As an example, suppose you attempt to place a TTable in edit mode and the
record you are attempting to edit is locked by another user.  In this case,
the OnRecLockFail event will be triggered and the ErrorTableName property will
contain the table name and the ErrorUserName will contain the name of the
user who currently has the record locked.

Well that's about it, if you have any questions or comments please let me
know at CServe ID 73302,2561 or you can give me a buzz at 407-246-0930.
Also, if you make any improvements to the component please send me a copy
so that I can implement in any future versions.  Currently, I plan on
adding security error trapping (Paradox tables only) as well as some goodies
for filters and packing.  What I'd like to see is a combination of all of 
the extended TTable components on the Delphi forum so that there is one 
component that contains all of these great features.

About me

I specialize in manufacturing applications, specifically make-to-order, and
am looking also to build some high level components for configurations and
bills of material.  I come from a FoxPro/Clipper background and am always 
happy to swap stories about the differences, likes/dislikes, regarding the 
two environments.  I personally don't like coding in FoxPro or Clipper too 
much anymore if you know what I mean.

Tim Young
OnTYme Software

Bug Fix and Enhancement History

8/24/95	-	Original TErrorTable
9/7/95	-	Fixed	problem with the BeforeEdit, BeforePost, etc. events
				getting turned off by the TErrorTable.  Added properties for
				ErrorFieldDispName for the "nice" field name from the DisplayLabel
				property of the TFields and ErrorFieldMinValue and 
				ErrorFieldMaxValue properties for retrieving the min/max string
				values when a min/max error occurs. Added event for "Multiple
				.NET files in use" exception (very common).
9/12/95	-	Fixed problem with error properties getting cleared due to an
				internal ordering problem with my BDE calls.  Also cleaned up
				the code a bit.
10/1/96	-	Added default message processing and proper handling of the Abort
				method when it was prudent to do so.  For example, if you're trying
				to open a table and receive an exception, chances are you don't
				want to continue attempting to use the program so the component
				issues an Abort to exit the program.  Added a new exception
				event - OnDetailRecordsExist. Added calls to DbiSaveChanges
				after each post, and added functionality for table callbacks so
				that whenever a table changes, whether by	the current user or
				another user on the network, the current table component will
				always be "fresh" and current.

10/18/96	-	Fixed problem with missing CodeLib unit declaration that should
				have not been in the USES clause.
				
******************************************************************************
I make no warranties regarding the use of this component and will not be held
responsible for any damages incurred from the use of this component.  I will
try to fix any bugs found in a reasonably timely manner, but in the case of
this not happening you have the source so fix it yourself.
******************************************************************************

(C) Copyright 1995,1996 OnTYme Software
